package yc.star.friend.service.impl;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import yc.star.common.domain.AppResult;
import yc.star.common.file.domain.OSSResult;
import yc.star.common.file.service.OSSService;
import yc.star.common.security.exception.ApplicationException;
import yc.star.friend.service.IFileService;

@Slf4j
@Service
public class FileServiceImpl implements IFileService {

    @Autowired
    private OSSService ossService;

    @Override
    public OSSResult upload(MultipartFile file) {
        try {
            return ossService.uploadFile(file);
        } catch (Exception e) {
            log.error(e.getMessage());
            throw new ApplicationException(AppResult.failed("文件上传失败"));
        }
    }

}